﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FilterItemDynamic.cs" company="None">
//   <Author>Adrian von Allmen, 2013</Author>
// </copyright>
// <summary>
//   Define a Filter Parameter which is dynamically
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace CrumbleLibrary
{
    using System.ComponentModel;

    /// <summary>
    /// Class for Create a Filter Parameter Item, which has to be handled dynamically
    /// </summary>
    public sealed class FilterItemDynamic : INotifyPropertyChanged
    {
        #region Internal Fields
        /// <summary>
        /// The Value within the object
        /// </summary>
        private object value;
        #endregion

        #region Ctor
        /// <summary>
        /// Initializes a new instance of the <see cref="FilterItemDynamic"/> class.
        /// </summary>
// ReSharper disable UnusedMember.Global
        public FilterItemDynamic()
// ReSharper restore UnusedMember.Global
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="FilterItemDynamic"/> class.
        /// </summary>
        /// <param name="name"> The ID Name. </param>
        /// <param name="labeltext"> The Text for Labeling. </param>
        /// <param name="type"> The renedering Type. </param>
        /// <param name="value"> The Value. </param>
        public FilterItemDynamic(string name, string labeltext, HelperLibrary.FilterType type, object value)
        {
            this.Name = name;
            this.LabelText = labeltext;
            this.Type = type;
            this.Value = value;
        }


        /// <summary>
        /// Initializes a new instance of the <see cref="FilterItemDynamic"/> class.
        /// </summary>
        /// <param name="name"> The ID Name. </param>
        /// <param name="labeltext"> The Text for Labeling. </param>
        /// <param name="type"> The renedering Type. </param>
        /// <param name="value"> The Value. </param>
        /// <param name="values"> The Multiple Values like from ListBoxes. </param>
        public FilterItemDynamic(string name, string labeltext, HelperLibrary.FilterType type, object value, object values)
        {
            this.Name = name;
            this.LabelText = labeltext;
            this.Type = type;
            this.Value = value;
            this.Values = values;
        }
        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        // ReSharper disable MemberCanBePrivate.Global
        // ReSharper disable UnusedAutoPropertyAccessor.Global
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the label text.
        /// </summary>
        public string LabelText { get; set; }

        /// <summary>
        /// Gets or sets the type.
        /// </summary>
        public HelperLibrary.FilterType Type { get; set; }

        /// <summary>
        /// Gets or sets the value.
        /// </summary>
        public object Value
        {
            get
            {
                return this.value;
            }

            set
            {
                this.value = value;
                this.OnPropertyChanged("Value");
            }
        }

        /// <summary>
        /// Gets or sets the Values on multiple selected items.
        /// </summary>
        public object Values { get; set; }

        // ReSharper restore UnusedAutoPropertyAccessor.Global
        // ReSharper restore MemberCanBePrivate.Global
        #endregion
        
        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
